﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using KeRui.Common;
using System.Collections.Generic;

public partial class Manage_Cms_TemplateList : System.Web.UI.Page
{
    public List<KeRui.Model.CmsTemplate> list;
    public KeRui.Model.CmsSite modelSite;
    protected void Page_Load(object sender, EventArgs e)
    {
        //登录
        ManageHelper.CheckAdminLogin();
        //权限
        ManageHelper.CheckAdminPower("system_templatelist");
        KeRui.BLL.CmsSite bllSite = new KeRui.BLL.CmsSite();
        modelSite = bllSite.GetModel(PageRequest.GetInt("siteid",-1));
        if(modelSite==null)
        {
            modelSite = new KeRui.Model.CmsSite();
            modelSite.ServerID=-1;
            modelSite.TemplateFolder = "";
        }

        KeRui.BLL.CmsTemplate bllTemplate = new KeRui.BLL.CmsTemplate();
        list = bllTemplate.GetList(modelSite.ServerID);

        foreach (KeRui.Model.CmsTemplate model in list)
        {
            if (IsCurSite(model.TemplateFolder))
            {
                Response.Redirect("TemplateFileList.aspx?siteid=" + modelSite.SiteID + "&TemplateID=" + model.TemplateID);
            }
        }
    }
    public bool IsCurSite(string TemplateFolder)
    {
        if (TemplateFolder.ToLower().Trim() == modelSite.TemplateFolder.ToLower().Trim())
            return true;
        else
            return false;
    }
}
